#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)

#include <stdio.h>
#include<stdlib.h>
typedef char BTDataType;

typedef struct BinaryTreeNode
{
    BTDataType _data;
    struct BinaryTreeNode* _left;
    struct BinaryTreeNode* _right;
}BTNode;

BTNode* prevOrder(char* str, int* pi)
{
    if (str[(*pi)] == '#')
    {
        (*pi)++;
        return NULL;
    }
    BTNode* root = (BTNode*)malloc(sizeof(BTNode));
    root->_data = str[(*pi)];
    (*pi)++;
    root->_left = prevOrder(str, pi);
    root->_right = prevOrder(str, pi);
    return root;
}

void InOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    InOrder(root->_left);
    printf("%c ", root->_data);
    InOrder(root->_right);
}

int main() {
    char str[100];
    scanf("%s", str);
    int i = 0;
    BTNode* root = prevOrder(str,&i);
    InOrder(root);
}